﻿using System;
using System.Collections.Generic;

namespace Librarinth
{
	public static class DataPool<S>
	{
		static readonly Register register	= new Register();
		public static S[] Datas { get; private set; }
		static public void Alloc(out int index)
		{
			register.Alloc(out index);
			if(Datas == null || index >= Datas.Length)
			{
				var datas	= Datas;
				int lenght	= datas == null ? 4 : datas.Length * 2;
				Array.Resize(ref datas,lenght);
				Datas	= datas;
			}
		}
		static public void Free(ref int index)
		{
			register.Free(ref index);
		}
	}
}
